package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.DeviceLifeSpanRecordDao;
import com.sugon.entity.DeviceLifeSpanRecordEntity;
import com.sugon.service.DeviceLifeSpanRecordService;
import com.sugon.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 设备运行寿命记录Service实现类
 *
 * @author sugon
 * @date 2022-09-05 16:32:32
 */
@Service("deviceLifeSpanRecordService")
public class DeviceLifeSpanRecordServiceImpl implements DeviceLifeSpanRecordService {
    @Autowired
    private DeviceLifeSpanRecordDao deviceLifeSpanRecordDao;

    @Override
    public DeviceLifeSpanRecordEntity queryObject(String id) {
        return deviceLifeSpanRecordDao.queryObject(id);
    }

    @Override
    public List<DeviceLifeSpanRecordEntity> queryList(Map<String, Object> map) {
        return deviceLifeSpanRecordDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return deviceLifeSpanRecordDao.queryTotal(map);
    }

    @Override
    public int save(DeviceLifeSpanRecordEntity deviceLifeSpanRecord) {
        deviceLifeSpanRecord.setId(RandomUtil.randomString(32));
        deviceLifeSpanRecord.setGmtCreate(DateUtil.date());
        deviceLifeSpanRecord.setCreateUser(ShiroUtils.getUserId());
        return deviceLifeSpanRecordDao.save(deviceLifeSpanRecord);
    }

    @Override
    public int update(DeviceLifeSpanRecordEntity deviceLifeSpanRecord) {
        return deviceLifeSpanRecordDao.update(deviceLifeSpanRecord);
    }

    @Override
    public int delete(String id) {
        return deviceLifeSpanRecordDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return deviceLifeSpanRecordDao.deleteBatch(ids);
    }
}
